﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Web;
using System.Web.Script.Serialization;
using System.Web.UI;
using System.Web.UI.WebControls;
using AgileNYCWebService.Manager.Data.Table;

namespace AgileNYCWebService
{
	public partial class SaveUserDetails : System.Web.UI.Page
	{
		protected void Page_Load(object sender, EventArgs e)
		{
			string url = "http://localhost:19368/AgileUsers.svc/SaveUserDetails";
			HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(url);
			request.Method = "POST";
			request.ContentType = "application/json; charset=utf-8";

			Users userDetails = new Users();
			userDetails.FirstName = "Hikmat";
			userDetails.LastName = "Rahimov";
			userDetails.Phone = "123456789";
			userDetails.Title = "title";
			userDetails.Company = "company";
			userDetails.Site = "site.com";
			userDetails.City = "city";
			userDetails.State = "state";
			userDetails.Info = "info";
			userDetails.AdditionalInfo = "";
			userDetails.SocialId = null;
			userDetails.SocialType = 1;
			userDetails.DeviceOs = 1;
			userDetails.DeviceId = null;
			userDetails.MobileWorkingSystem = 2;
			userDetails.UserToken = "PNx4SxuqoUSjFaKtaAI/Tg==";


			StreamWriter writer = new StreamWriter(request.GetRequestStream());
			JavaScriptSerializer jss = new JavaScriptSerializer();
			string yourdata = jss.Serialize(userDetails);
			writer.Write(yourdata);
			writer.Close();

			using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
			{
				System.IO.StreamReader sr = new System.IO.StreamReader(response.GetResponseStream());
				String s = sr.ReadToEnd().Trim();
				string result = s;
			}
		}
	}
}